<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
<script>
wx.config({
  debug: false,
    appId:'${appId}',
    timestamp: '${timestamp}',
    nonceStr: '${nonceStr}',
    signature: "${signature}",
    jsApiList: [
      'checkJsApi',
      'onMenuShareTimeline',
      'onMenuShareAppMessage'
    ]
});	

wx.ready(function () {
 wx.onMenuShareTimeline({
     title: '吃水果就来果然FruitC啦。。。',
     link: '${urlXX}?${user_key.openid}',//在这里直接${url}会取到微信当前的Url
     desc: '吃水果就来果然FruitC啦。。。',
     imgUrl: 'http://g.grfruitc.top/logo.png',
     trigger: function (res) {
       //alert('用户点击分享到朋友圈');
     },
     success: function (res) {
       var isGet = "${user_key.shareget}";
       if(!"1" == isGet){//首次分享
      	 $.ajax({
      		 url : "${ctx}/sendYhq"
      	 });
      	 alert("优惠券已经送到您的账户中啦，快去吃橙子啦！");
       }
     },
     cancel: function (res) {
       //alert('已取消');
     },
     fail: function (res) {
       //alert(JSON.stringify(res));
     }
   });
 wx.onMenuShareAppMessage({
   title: '果然FruitC',
   desc: '您身边的水果之家。。。',
   link: '${urlXX}?${user_key.openid}',//在这里直接${url}会取到微信当前的Url
   imgUrl: 'http://g.grfruitc.top/logo.png',
   trigger: function (res) {
     //alert('用户点击发送给朋友');
   },
   success: function (res) {
    // alert('已分享');
   },
   cancel: function (res) {
    // alert('已取消');
   },
   fail: function (res) {
     //alert(JSON.stringify(res));
   }
 });
});
</script>